#pragma once

#include <windows.h>
#include <XInput.h>

namespace Xiol
{

/*
	ControllerState
	This is a wrapper around the XINPUT_GAMEPAD struct
	It provides copy construction, assignment and access to the underlying state
*/
class ControllerState
{
public:
	ControllerState();
	ControllerState( const XINPUT_GAMEPAD& gamepadStruct );
	ControllerState( const ControllerState& other );
	ControllerState& operator=( const ControllerState& other );
	
	// The buttonID is an XINPUT_GAMEPAD_XXXX value (*not* an index)
	bool isButtonPressed( WORD buttonID ) const;		
	
	// The triggerID is 0 for left and 1 for right
	// The trigger value is expressed in the [0..255] range
	BYTE getTriggerPosition( int triggerID ) const;			
	
	// The thumbstickID is 0 for left and 1 for right
	// The position on x and y is expressed in the [-32768..32767] range
	void getThumbstickPosition( int thumbstickID, SHORT& positionX, SHORT& positionY ) const; 

private:
	XINPUT_GAMEPAD mGamepadStruct;
};

}
